Table Inventory
Inventory manipulation
Functions
| GiveItem(objectID, [count], [addToPickupSummary]) | Add an item to the player's inventory. |
| TakeItem(Object, [count]) | Remove an item from the player's inventory. |
| GetItemCount(objectID) | Get the amount of an item held in the player's inventory. |
| SetItemCount(objectID, count) | Set the amount of an item in the player's inventory. |
| UseItem(objectID) | Try to use an item. |
| GetUsedItem() | Get last item that was used in the player's inventory. |
| SetUsedItem(objectID) | Set last item that was used in the player's inventory. |
| ClearUsedItem() | Clear last item used in the player's inventory. |
| GetFocusedItem() | Gets the item that is about to be focused in the inventory. |
| SetFocusedItem(objectID) | Opens the inventory and focuses on the specified item, if it is available. |
| ConvertObjectToInventoryItem(objectID) | Converts object ID to inventory item ID. |
| ConvertInventoryItemToObject(inventoryID) | Converts inventory item ID to object ID. |
| ResetToDefault() | Resets inventory to a default state. |
Functions
- GiveItem(objectID, [count], [addToPickupSummary])
-
Add an item to the player's inventory.
Parameters:
- objectID ObjID Object ID of the item to add.
- count int The amount of items to add. Default is the yield from a single pickup, e.g. 1 from a medipack, 12 from a flare pack. Default: 1.
- addToPickupSummary bool If true, display the item in the pickup summary. Default is false. Default: false.
- TakeItem(Object, [count])
-
Remove an item from the player's inventory.
Parameters:
- Object ObjID ID of the item to remove.
- count int The amount of items to remove. Default is the yield from a single pickup, e.g. 1 from a medipack, 12 from a flare pack. Default: 1.
- GetItemCount(objectID)
-
Get the amount of an item held in the player's inventory.
Parameters:
- objectID ObjID Object ID of the item to check.
Returns:
-
int
The amount of items. -1 indicates infinity.
- SetItemCount(objectID, count)
-
Set the amount of an item in the player's inventory.
Parameters:
- objectID ObjID Object ID of the item amount to set.
- count int The amount of items to set. -1 indicates infinity.
- UseItem(objectID)
-
Try to use an item.
For equippable or consumable items, standard game conditions will apply - for example, firearms can't be used underwater, and keys or puzzle items
can only be used in close proximity to a corresponding key or puzzle hole.
Parameters:
- objectID ObjID Object ID to use. Must be preset in the inventory.
- GetUsedItem()
-
Get last item that was used in the player's inventory.
This value will be valid only for a single frame after exiting inventory, after which Lara says "No".
Therefore, this function must be preferably used either in OnLoop or OnUseItem events.
Returns:
-
ObjID
Last item used in the inventory.
- SetUsedItem(objectID)
-
Set last item that was used in the player's inventory.
Will only be valid for the next frame. If not processed by the game, Lara will say "No".
Parameters:
- objectID ObjID Object ID of the item to select from inventory. Must be preset in the inventory.
- ClearUsedItem()
- Clear last item used in the player's inventory. When this function is used in OnUseItem level function, it allows to override existing item functionality. For items without existing functionality, this function is needed to avoid Lara saying "No" after using it.
- GetFocusedItem()
-
Gets the item that is about to be focused in the inventory.
Can be used to intercept inventory calls with a request to select a particular item.
Returns:
-
ObjID
objectID Object ID of the item set.
- SetFocusedItem(objectID)
-
Opens the inventory and focuses on the specified item, if it is available.
Parameters:
- objectID ObjID Object ID of the item to set. Must be preset in the inventory.
- ConvertObjectToInventoryItem(objectID)
-
Converts object ID to inventory item ID. To be used by custom inventory module.
Parameters:
- objectID ObjID Object ID of the item to convert.
Returns:
-
int
Inventory item ID of the object.
- ConvertInventoryItemToObject(inventoryID)
-
Converts inventory item ID to object ID. To be used by custom inventory module.
Parameters:
- inventoryID int Inventory item ID to convert.
Returns:
-
ObjID
Object ID of the item.
- ResetToDefault()
- Resets inventory to a default state. Clears inventory item list and adds default set of items, including a compass, pistols, 3 flares, 3 small medipacks, and 1 large medipack.